<template>
	<view style="background: white;height: 100vh;">

		<view class="add_item">
			<view>主业务员</view>
			<view @click.stop="openSearch('all_user3')">
				<text>{{businessContact.name}}</text>
				<image src="/static/images/right.png" class="right"></image>
			</view>
		</view>
		<!-- <view class="add_item">
			<view>售后负责人</view>
			<view @click.stop="openSearch('all_user2')">
				<text>{{afterSale.name}}</text>
				<image src="/static/images/right.png" class="right"></image>
			</view>
		</view> -->
		<view class="save" @tap="save()">保存</view>
	</view>
</template>

<script>
	import {
		deepClone
	} from '@/static/js/index.js'
	export default {
		data() {
			return { 
				afterSale:{//售后负责人
					name:'',
					id:''
				},
				businessContact:{//业务联系人
					name:'',
					id:''
				},
				customerId:0, // 客户id
			}
		},
		onLoad(options) {
			console.log("参数----》》》》",options);
			this.afterSale = JSON.parse(options.sale);
			this.businessContact = JSON.parse(options.contact);
			this.customerId = options.customerId;
		}, 
		onShow() {
			this.setBaseNews();
		},
		methods: {
			save(){
				//  sale_user_id contact_user_id   user_id customer_id
				console.log("客户id----》》》",this.customerId);
				let upJson = {
						user_id:uni.getStorageSync("userId"),
						customer_id:this.customerId,  
						contact_user_id:this.businessContact.id
					}
				this.$api.getTransferCustomer(upJson)

			},
			//设置基础信息
			setBaseNews(){
				let obj=deepClone(this.$store.getters['parameters/searchObj']);
				if(obj.key=="all_user2"){
					this.afterSale={
						name:obj.data.username,
						id:obj.data.id
					}
				}else if(obj.key=="all_user3"){
					this.businessContact={
						name:obj.data.username,
						id:obj.data.id
					}
				}
				this.$store.dispatch('parameters/deleteObj');
			},
			// 选择员工
			openSearch(key){
				uni.navigateTo({
					url:'/pages/searchList/searchList?searchKey='+key
				})
			},
			getPickerValue(e) {
				switch (e.currentTarget.dataset.index) {
					case 0:
					this.mainSalesmanIndex=e.detail.value;
						break;
					case 1:
					this.afterSaleIndex=e.detail.value;
						break;
				}
			}
		}
	}
</script>

<style>

</style>
